package com.xfly.app.ui;

import android.os.Bundle;
import android.widget.TextView;

import com.ptmall.app.R;
import com.ptmall.app.base.BaseMvpActivity;
import com.ptmall.app.bean.ProductBean;
import com.ptmall.app.net.api.ApiDataRepository;
import com.ptmall.app.net.base.ApiNetResponse;
import com.ptmall.app.view.NoScrollListView;
import com.ptmall.app.view.TitleBarView;
import com.xfly.app.adapter.WlAdapter;
import com.xfly.app.adapter.WlGoodAdapter;
import com.xfly.app.bean.WlBean;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CkwlActivity extends BaseMvpActivity {


    TitleBarView title_bar;
    WlAdapter wlAdapter;
    WlGoodAdapter wlGoodAdapter;
    NoScrollListView listview2,listview;
    String id;
    ApiDataRepository apiDataRepository = ApiDataRepository.getInstance();
    TextView address;
    private List<ProductBean> mDataList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setView(R.layout.activity_ckwl);
    }

    @Override
    public void initViews() {
        mDataList = (List<ProductBean>) getIntent().getSerializableExtra("list");
        id = getIntent().getStringExtra("id");
        title_bar = findViewById(R.id.title_bar);
        listview2 = findViewById(R.id.listview2);
        address = findViewById(R.id.address);
        listview = findViewById(R.id.listview);

        title_bar.setText("查看物流");
        title_bar.setOnTitleBarClickListener(new TitleBarView.TitleBarClickListener() {
            @Override
            public void leftClick() {
                finish();
            }

            @Override
            public void rightClick() {

            }
        });
    }

    @Override
    public void initEvents() {
        wlGoodAdapter = new WlGoodAdapter(getContext(),mDataList);
        listview.setAdapter(wlGoodAdapter);
        getData();
    }

    private void getData(){
        Map<String,String> map = new HashMap<>();
        map.put("orders_id",id);
        apiDataRepository.wl(map, new ApiNetResponse<WlBean>() {
            @Override
            public void onSuccess(WlBean data) {
                wlAdapter = new WlAdapter(getContext(),data.express);
                listview2.setAdapter(wlAdapter);
                address.setText("[收货地址]"+data.orders.address_address);
            }
        });
    }
}

